load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBJNI_TARGET", "IS_OSS_BUILD", "react_native_dep", "react_native_target", "react_native_xplat_target", "rn_android_library", "rn_xplat_cxx_library")

rn_android_library(
    name = "FBReactNativeSpec",
    srcs = glob(["*.java"]),
    visibility = ["PUBLIC"],
    deps = [
        react_native_dep("third-party/java/jsr-305:jsr-305"),
        react_native_dep("third-party/java/jsr-330:jsr-330"),
        react_native_target("java/com/facebook/react/bridge:bridge"),
        react_native_target("java/com/facebook/react/common:common"),
    ],
    exported_deps = [
        react_native_target("java/com/facebook/react/turbomodule/core/interfaces:interfaces"),
    ],
)

rn_xplat_cxx_library(
    name = "FBReactNativeSpec-jni",
    srcs = [
        "jni/FBReactNativeSpec-generated.cpp",
    ],
    headers = {
        "FBReactNativeSpec/FBReactNativeSpec.h": "jni/FBReactNativeSpec.h",
    },
    header_namespace = "",
    exported_headers = {
        "FBReactNativeSpec/FBReactNativeSpec.h": "jni/FBReactNativeSpec.h",
    },
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=c++14",
        "-Wall",
    ],
    labels = ["supermodule:android/default/public.react_native.infra"],
    platforms = (ANDROID,),
    preprocessor_flags = [
        "-DLOG_TAG=\"ReactNative\"",
        "-DWITH_FBSYSTRACE=1",
    ],
    visibility = [
        "PUBLIC",
    ],
    deps = [
        FBJNI_TARGET,
        "//xplat/folly:molly",
        "//xplat/jsi:JSIDynamic",
        react_native_target("jni/react/jni:jni"),
        react_native_xplat_target("cxxreact:bridge"),
    ],
    exported_deps = ([
        react_native_xplat_target("turbomodule/core:core"),
    ]) + ([
        "//xplat/jsi:jsi",
    ]) if not IS_OSS_BUILD else [],
)
